home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 11: TSX-11
/
Linux Cubed Series 11 - TSX-11 Vol 1.iso
/
usr.bin
/
hostname.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-30
|
456b
|
28 lines
/*
* Set or display hostname. Jeff Comstock - Bloomington, MN USA 1992
* Usage: hostname [name]
* Only root may change the hostname.
*/
#include <stdio.h>
#include <unistd.h>
main(int argc, char **argv) {
struct utsname uts;
if ( argc == 2 ) {
if ( sethostname(argv[1],strlen(argv[1]))) {
perror("sethostname");
exit(1);
}
}
else {
if (uname(&uts)) {
perror("uname");
exit(1);
}
else
puts(uts.nodename);
}
return(0);
}